/**
* AutoSWF - Cody Cushing. March 26, 2009
* Copyright (c) 2009 Cody Cushing
* No use restrictions. Maintain this notice in all versions. 
**/

package com.autoswf.taskrunner.loadtasks
{
	import com.autoswf.taskrunner.IRequest;
	
	import flash.display.Loader;
	import flash.net.URLLoader;
	
	import flexunit.framework.TestCase;

	public class LoadTaskFactoryTest extends TestCase
	{
		private var taskFactory:LoadTaskFactory;
		
		public function LoadTaskFactoryTest(methodName:String=null)
		{
			super(methodName);
		}
		
		override public function setUp():void
		{
			taskFactory = new LoadTaskFactory();
		}
		
		
		/** Test that a UrlLoaderTask is used. */		
		public function testData01():void
		{
			var request:IRequest = new LoadRequest("", "xml");
			assertTrue(taskFactory.getTask(request) is URLLoaderTask);
		}
		
		
		/** Test that a UrlLoaderTask is used. */
		public function testData02():void
		{
			var request:IRequest = new LoadRequest("", "string");
			assertTrue(taskFactory.getTask(request) is URLLoaderTask);
		}
		
		
		/** Test that a UrlLoaderTask is used. */
		public function testData03():void
		{
			var request:IRequest = new LoadRequest("", "urlloader");
			assertTrue(taskFactory.getTask(request) is URLLoaderTask);
		}
		
		
		/** Test that a UrlLoaderTask is used. */		
		public function testData04():void
		{
			var request:IRequest = new LoadRequest("", URLLoader);
			assertTrue(taskFactory.getTask(request) is URLLoaderTask);
		}
		
		
		/**
		 * Test that a LoaderTask is used.
		 */		
		public function test01():void
		{
			var request:IRequest = new LoadRequest("", "swf");
			assertTrue(taskFactory.getTask(request) is LoaderTask);
		}
		

		/**
		 * Test that a LoaderTask is used.
		 */		
		public function test02():void
		{
			var request:IRequest = new LoadRequest("", "jpg");
			assertTrue(taskFactory.getTask(request) is LoaderTask);
		}
		
		
		/**
		 * Test that a LoaderTask is used.
		 */		
		public function test03():void
		{
			var request:IRequest = new LoadRequest("", "png");
			assertTrue(taskFactory.getTask(request) is LoaderTask);
		}
		
		
		/**
		 * Test that a LoaderTask is used.
		 */		
		public function test04():void
		{
			var request:IRequest = new LoadRequest("", "gif");
			assertTrue(taskFactory.getTask(request) is LoaderTask);
		}
		
		/**
		 * Test that a LoaderTask is used.
		 */		
		public function test05():void
		{
			var request:IRequest = new LoadRequest("", "image");
			assertTrue(taskFactory.getTask(request) is LoaderTask);
		}
		
	
		/**
		 * Test that a LoaderTask is used.
		 */		
		public function test06():void
		{
			var request:IRequest = new LoadRequest("", Loader);
			assertTrue(taskFactory.getTask(request) is LoaderTask);
		}
		
	
		/**
		 * Test that a LoaderTask is not returned for a non loader type.
		 */		
		public function test07():void
		{
			try
			{
				assertNull(taskFactory.getTask(new LoadRequest("", "nonLoaderType")));
			}
			catch(error:ArgumentError)
			{ }
		}
		
	}
}